﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using PMServiceDesk.Web.AppCode;

namespace PMServiceDesk.Web.Forms.PaginaPublica
{
    public partial class FileUpload : System.Web.UI.Page
    {
        protected void UploadFileToServer()
        {
            string id = FileIU.UploadFile(PUBLIC_fileUpload, (PUBLIC_hiddenFileServer.Value == "1"));

            PUBLIC_hiddenIdFileUpload.Value = id;

            string functionCallBack = PUBLIC_hiddenCallBack.Value;
            functionCallBack = "window.parent." + functionCallBack + "(" + id + ");";

            ClientScript.RegisterClientScriptBlock(this.GetType(), "FileUpload", functionCallBack, true);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            string control = Request.Params.Get("__EVENTTARGET") == null ? string.Empty : Request.Params.Get("__EVENTTARGET");

            if (control == "postbackSubmitFileUpload") this.UploadFileToServer();
        }
    }
}